// 验证数据库中的用户和密码和手机是否存在
const User = {

  // 查询用户名|手机号
  queryUserName (option) {
    return "select * from user where name = '" + option.userName + "' or phone = '" + option.userName + "'  "
  },
  // 查询用户名|手机号===》密码
  queryUserPwd (option) {
    return "select * from user where (name = '" + option.userName + "' or phone = '" + option.userName + "') and password = '" + option.userPwd + "' "
  },
  // 增加一条用户记录
  insertData (option) {
    const userName = option.userName
    // 引入插件
    const jwt = require('jsonwebtoken')
    // 用户信息
    const payload = { name: userName }
    // 口令==》品牌
    const secret = 'xiaoluxian'
    const token = jwt.sign(payload, secret)
    return 'insert into user (name,phone,password,nick,imgUrl,token) values ("","' + option.userName + '","666666","' + option.userName + '","img/nick.png","' + token + '")'
  }
}

exports = module.exports = User
